package qgs.zisu.javaconcurrency.javaconcurrency.chapter4_DaemonThread;

import java.util.Optional;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/22 14:57
 * @Version 1.0
 * 线程优先级
 */
public class ThreadSimpleAPI2 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
           for(int i = 0;i<1000;i++){
               Optional.of(Thread.currentThread().getName()+"-Index"+i).ifPresent(System.out::println);
           }
        });
        t1.setPriority(Thread.MAX_PRIORITY);

        Thread t2 = new Thread(()->{
            for(int i = 0;i<1000;i++){
                Optional.of(Thread.currentThread().getName()+"-Index"+i).ifPresent(System.out::println);
            }
        });
        t2.setPriority(Thread.NORM_PRIORITY);

        Thread t3  = new Thread(()->{
            for(int i = 0;i<1000;i++){
                Optional.of(Thread.currentThread().getName()+"-Index"+i).ifPresent(System.out::println);
            }
        });
        t1.setPriority(Thread.MIN_PRIORITY);

        t1.start();
        t2.start();
        t3.start();
    }
}
